import { Rule, RuleType } from "@midwayjs/validate";
import { PageDTO } from "@dto/common/page.dto";

// 查询参数
export class ListRoleDTO extends PageDTO {
  @Rule(RuleType.string())
  roleName?: string;

  @Rule(RuleType.string())
  roleKey?: string;

  @Rule(RuleType.string())
  status?: string;

  @Rule(RuleType.string())
  'params[beginTime]'?: string;

  @Rule(RuleType.string())
  'params[endTime]'?: string;
}

// 新增参数
export class CreateRoleDTO {
  @Rule(RuleType.string().required())
  roleName: string;

  @Rule(RuleType.string().required().max(20))
  roleKey: string;

  @Rule(RuleType.number().required().min(0))
  roleSort: number;

  @Rule(RuleType.string().required())
  status: string;

  @Rule(RuleType.boolean())
  deptCheckStrictly?: boolean;

  @Rule(RuleType.boolean())
  menuCheckStrictly?: boolean;

  @Rule(RuleType.array())
  menuIds?: Array<number>;

  @Rule(RuleType.array())
  deptIds?: Array<number>;

  @Rule(RuleType.string().max(500).allow(null, ""))
  remark?: string;
}

// 修改参数
export class UpdateRoleDTO extends CreateRoleDTO{
  @Rule(RuleType.number().required())
  roleId: number;
}

// 授权用户列表
export class ListAuthUserDTO extends PageDTO {
  @Rule(RuleType.number())
  roleId?: number;

  @Rule(RuleType.string())
  userName?: string;

  @Rule(RuleType.string().max(11))
  phonenumber?: string;
}

// 取消授权用户
export class CancelAuthUserDTO {
  @Rule(RuleType.number().required())
  roleId: number;

  @Rule(RuleType.number().required())
  userId: number;
}

// 批量 取消授权用户
export class BatchCancelAuthUserDTO {
  @Rule(RuleType.number().required())
  roleId: number;

  @Rule(RuleType.string().required())
  userIds: string;
}

// 批量 绑定授权用户
export class BatchBindAuthUserDTO {
  @Rule(RuleType.number().required())
  roleId: number;

  @Rule(RuleType.string().required())
  userIds: string;
}
